In a conventional mobile network, a data communication path between terminals needs to go through a core network entity serving gateway (SGW)/packet data gateway (PGW). In this case, data transmission also needs to go through a core network when being performed by two terminals that are quite close to each other, and data transmission efficiency is low.
To resolve this problem, a proximity service (ProSe) topic is proposed in the industry, so that data transmission can be directly performed by the two terminals that are relatively close to each other without going through the core network, and efficiency of data transmission between terminals that are relatively close to each other can be improved. That the terminals discover each other is an important part of a ProSe, and is also a premise of the data transmission between the terminals.
It is assumed that a terminal 1 and a terminal 2 are two terminals that are quite close to each other, the terminal 1 performs broadcasting, and the terminal 2 performs monitoring. In the prior art, a process of discovering the terminal 1 by the terminal 2 may include: the terminal 1 obtains a user code word of the terminal 1 and broadcasts the user code word; the terminal 2 first obtains the user code word of the terminal 1, and then filters, by using the user code word, the user code word of the terminal 1 from all user code words detected by the terminal 2; the terminal 2 sends the filtered user code word of the terminal 1 to a ProSe entity; and the ProSe entity searches for a correspondence between a user code word and a terminal identifier according to the received user code word of the terminal 1, obtains a terminal identifier of the terminal 1, and sends the obtained terminal identifier of the terminal 1 to the terminal 2. In this way, the terminal 2 can discover the terminal 1 according to an identifier of the terminal 1.
However, the foregoing process has the following problem: When the terminal 2 needs to monitor multiple terminals (for example, the terminal 2 needs to monitor 20 terminals), the terminal 2 may obtain user code words of the 20 terminals, and the terminal 2 needs to filter, by using 20 user code words separately, the 20 user code words that need to be monitored by the terminal 2 from all the user code words detected by the terminal 2. Generally, a quantity of user code words that can be detected by a terminal is relatively large (for example, the terminal 2 can detect 1000 user code words), that is, the terminal 2 needs to filter, by using the 20 user code words separately, the 20 user code words that need to be monitored by the terminal 2 from the 1000 user code words detected by the terminal 2. A process of filtering the user code word by the terminal 2 is relatively complex, and energy consumption of the terminal 2 is increased.